package com.itboye.lottery.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.itboye.lottery.R;
import com.itboye.lottery.bean.IndexDataBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wu on 2018/1/9.
 */

public class HomeBottomMatchJiaoDianAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context context;
    List<IndexDataBean.Fast_arr> classEntityArrayList = new ArrayList<>();

    public HomeBottomMatchJiaoDianAdapter(List<IndexDataBean.Fast_arr> classEntityArrayList) {
        this.classEntityArrayList = classEntityArrayList;
    }

    public OnItemClickListener itemClickListener;

    public void setOnItemClickListener(HomeBottomMatchJiaoDianAdapter.OnItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }


    public interface OnItemClickListener {
        void onItemClick(View view, int position);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        return new ViewHolderChild2(LayoutInflater.from(context).inflate(R.layout.item_home_bottom_classifycation_type_2, parent, false));
    }

    @Override
    public int getItemViewType(int position) {
        return classEntityArrayList.get(position).getType();
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//        GlideUtil.display(context, list.get(position).getImg_url(), holder.img);
//        holder.name.setText(list.get(position).getClassification_name());
    }

    @Override
    public int getItemCount() {
        return classEntityArrayList == null ? 0 : classEntityArrayList.size();
    }

    public class ViewHolderChild extends RecyclerView.ViewHolder implements View.OnClickListener {
        public ImageView img;
        public TextView name;
        public LinearLayout ll_number;

        public ViewHolderChild(View itemView) {
            super(itemView);
            ll_number = itemView.findViewById(R.id.ll_number);
//            img = itemView.findViewById(R.id.img);
//            name = itemView.findViewById(R.id.name);
//
//            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
//            if (itemClickListener != null) {
//                itemClickListener.onItemClick(v, getAdapterPosition());
//            }
        }
    }

    public class ViewHolderChild2 extends RecyclerView.ViewHolder implements View.OnClickListener {
        public ImageView img;
        public TextView name;

        public ViewHolderChild2(View itemView) {
            super(itemView);
//            img = itemView.findViewById(R.id.img);
//            name = itemView.findViewById(R.id.name);
//
//            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
//            if (itemClickListener != null) {
//                itemClickListener.onItemClick(v, getAdapterPosition());
//            }
        }
    }

    public class ViewHolderTitle extends RecyclerView.ViewHolder implements View.OnClickListener {
        public ImageView img;
        public TextView name;

        public ViewHolderTitle(View itemView) {
            super(itemView);
//            img = itemView.findViewById(R.id.img);
//            name = itemView.findViewById(R.id.name);
//
//            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
//            if (itemClickListener != null) {
//                itemClickListener.onItemClick(v, getAdapterPosition());
//            }
        }
    }
}
